from sklearn.preprocessing import MinMaxScaler, StandardScaler
import pandas as pd
import numpy as np


# 1. 归一化
# 1.1 读取数据
data = pd.read_csv('./big_data/dating.txt')
# print(data)

# 1.2 创建转换器
transfer = MinMaxScaler(feature_range=(0, 1))  # 指定生成的数据在数学上在区间[0,1]的数
# 1.3 生成数据
new_data = transfer.fit_transform(data[['milage','Liters','Consumtime']])

# print(np.any(new_data>=1))

# 2. 标准化
p = pd.read_csv('./big_data/dating.txt')

t = StandardScaler()
n = t.fit_transform(p[['milage','Liters','Consumtime']])

print(n)
print('每一列的平均值为:', t.mean_)
print('每一列的房差为:', t.var_)




